<%--
  Created by IntelliJ IDEA.
  User: 22954
  Date: 2024/8/31
  Time: 4:29
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>域对象</title>
</head>
<body>
<%
    /*
    JSP四大域对象----pageContext | request | session | application
    pageContext作用域为当前页面(当前jsp)
    request作用域为request的作用域(多数用于请求转发)
    session作用域为session的作用域
    application作用域为全局作用域,生命周期与服务器(Tomcat)同步
     */
    pageContext.setAttribute("a","pageContext");
    request.setAttribute("a", "request");
    session.setAttribute("a", "session");
    application.setAttribute("a", "application");
%>
pageContext.getAttribute:<%=pageContext.getAttribute("a")%><br/><br/>
request.getAttribute:<%=request.getAttribute("a")%><br/><br/>
session.getAttribute:<%=session.getAttribute("a")%><br/><br/>
application.getAttribute:<%=application.getAttribute("a")%><br/><br/>
<%
    //request.getRequestDispatcher("/scope2.jsp").forward(request, response);
    String contextPath = request.getContextPath();
    response.sendRedirect(contextPath + "/scope2.jsp");
%>
</body>
</html>
